Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

chore(base images): decouple build of base images to separate gh-action #464

Merged
merged 4 commits into from
Oct 5, 2021

Conversation

vitaliy-guliy
Copy link
Contributor

@vitaliy-guliy vitaliy-guliy commented Sep 7, 2021

Signed-off-by: Vitaliy Gulyy vgulyy@redhat.com

What does this PR do?

Introduces a set of dockerfiles and scripts withing GitHub actions to build sidecar images.

Sidecar dockerfiles are placed in dockerfiles directory. This directory contains as well build.sh script to build all or specific sidecar image(s).

GitHub actions / Workflow

  1. check-sidecar-image-digests.yml - Sidecar Digest validation
    Checks sidecar parent image on updates.

The action runs ./build/workflows/check-sidecar-image-digests.sh --pr.
This script

  • checks whether tag of sidecar base image was updated (has new digest)
  • update dockerfiles and create pull request with changes

We will merge this pull request by hands.

  1. build-sidecar-images-on-push.yml - Rebuild Sidecar Images / Push to Master
    The action is triggered when merging anything to main branch to dockerfiles directory.

Action runs ./build/workflows/build-sidecar-images-on-push.sh --push --rm --update-devfiles, which

  • detects which dockerfile was changed, rebuilds corresponding sidecar image using dockerfiles/build.sh script. All the sidecar images will be rebuilt if changes were in base.dockerfile, entrypoint.sh or in install-editor-tooling.sh
  • pushes built sidecars to quay.io
  • updates devfiles / bumps sidecar references to new tags

On the next step action runs ./build/workflows/bump-devfiles-to-new-sidecar-tags.sh --pr which

  • checks whether devfiles were updated
  • commits changes and creates pull request

We will merge this pull request by hands.

Following improvement

Release scripts will be fixed after merging this PR and pushing new sidecar images (with new tags) to quay.io.
Usage of base_images file will be also cut when refactoring the release scripts.

Screenshot/screencast of this PR

What issues does this PR fix or reference?

eclipse-che/che#19695

How to test this PR?

  1. Build sidecars from sources
  • clone repository
  • switch to che-19695 branch
  • run scripts by hands
2. Test with devfile
---
apiVersion: 1.0.0
metadata:
  generateName: java-mysql-
projects:
  -
    name: web-java-spring-petclinic
    source:
      type: git
      location: "https://github.com/che-samples/java-spring-petclinic"
      branch: main
components:
  -
    type: chePlugin
    id: redhat/java8/latest
  -
    type: dockerimage
    alias: tools
    # image: quay.io/eclipse/che-java8-maven:next
    image: quay.io/vgulyy/che-java8-maven:b12c1a8
    env:
      - name: MAVEN_CONFIG
        value: ""
      - name: JAVA_OPTS
        value: "-XX:MaxRAMPercentage=50.0 -XX:+UseParallelGC -XX:MinHeapFreeRatio=10
          -XX:MaxHeapFreeRatio=20 -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90
          -Dsun.zip.disableMemoryMapping=true -Xms20m -Djava.security.egd=file:/dev/./urandom
          -Duser.home=/home/user"
      - name: MAVEN_OPTS
        value: $(JAVA_OPTS)
    memoryLimit: 1000Mi
    endpoints:
      - name: '8080-tcp'
        port: 8080
      - name: 'debug'
        port: 5005
        attributes:
          public: 'false'
    mountSources: true
    volumes:
      - name: m2
        containerPath: /home/user/.m2
  -
    type: dockerimage
    alias: mysql
    image: quay.io/eclipse/che--centos--mysql-57-centos7:latest-e08ee4d43b7356607685b69bde6335e27cf20c020f345b6c6c59400183882764
    env:
      - name: MYSQL_USER
        value: petclinic
      - name: MYSQL_PASSWORD
        value: petclinic
      - name: MYSQL_DATABASE
        value: petclinic
      - name: PS1
        value: $(echo ${0})\\$
    memoryLimit: 300Mi
    endpoints:
      - name: 'db'
        port: 3306
        attributes:
          discoverable: "true"
          public: "false"
    mountSources: true
commands:
  -
    name: 2. Maven build
    actions:
      -
        type: exec
        component: tools
        command: "mvn clean install"
        workdir: "${CHE_PROJECTS_ROOT}/web-java-spring-petclinic"
  -
    name: 3. Run webapp
    actions:
      -
        type: exec
        component: tools
        command: |
          java -jar -Dspring-boot.run.profiles=mysql \
          -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 \
          target/*.jar
        workdir: ${CHE_PROJECTS_ROOT}/web-java-spring-petclinic
  -
    name: 1. Prepare database
    actions:
    -
      type: exec
      component: mysql
      command: |
        /opt/rh/rh-mysql57/root/usr/bin/mysql -u root < ${CHE_PROJECTS_ROOT}/web-java-spring-petclinic/src/main/resources/db/mysql/user.sql && \
        /opt/rh/rh-mysql57/root/usr/bin/mysql -u root petclinic < ${CHE_PROJECTS_ROOT}/web-java-spring-petclinic/src/main/resources/db/mysql/schema.sql && \
        /opt/rh/rh-mysql57/root/usr/bin/mysql -u root petclinic < ${CHE_PROJECTS_ROOT}/web-java-spring-petclinic/src/main/resources/db/mysql/data.sql && \
        echo -e "\e[32mDone.\e[0m Database petclinic was configured!"
  - name: Debug remote java application
    actions:
      - type: vscode-launch
        referenceContent: |
          {
          "version": "0.2.0",
          "configurations": [
            {
              "type": "java",
              "name": "Debug (Attach) - Remote",
              "request": "attach",
              "hostName": "localhost",
              "port": 5005
            }]
          }

PR Checklist

As the author of this Pull Request I made sure that:

Reviewers

Reviewers, please comment how you tested the PR when approving it.

@vitaliy-guliy vitaliy-guliy changed the title chore(base images): switch from digests to tags chore(base images): decouple build of base images to separate gh-action Sep 8, 2021
… image

Signed-off-by: Vitaliy Gulyy <vgulyy@redhat.com>
make-release.sh Outdated Show resolved Hide resolved
Signed-off-by: Vitaliy Gulyy <vgulyy@redhat.com>
Signed-off-by: Vitaliy Gulyy <vgulyy@redhat.com>
.github/workflows/build-sidecar-images-on-push.yml Outdated Show resolved Hide resolved
build/workflows/build-sidecar-images-on-push.sh Outdated Show resolved Hide resolved
build/workflows/bump-devfiles-to-new-sidecar-tags.sh Outdated Show resolved Hide resolved
build/workflows/check-sidecar-image-digests.sh Outdated Show resolved Hide resolved
Signed-off-by: Vitaliy Gulyy <vgulyy@redhat.com>
Copy link
Contributor

@svor svor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I've tried to build all images and specific one, have not detected any problem.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants